﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Xqsys.DAL
{
    public class LeaveWork
    {
        public bool AddLeaveWord(MODEL.LeaveWords leaveWord)
        {
            SqlParameter[] param = new SqlParameter[]
            {

                new SqlParameter("@username",leaveWord.UserName),
               // new SqlParameter("@userIp",leaveWord.UserIp),
                new SqlParameter("@content",leaveWord.Content),
                new SqlParameter("@time",leaveWord.Intime)
            };
            return COM.SqlHelper.ExecuteNonQuery("sp_AddLeaveWord", param);
        }
        public bool DeleteLeaveWord(int LWid )
        {
            string word="该留言已被该作者删除！";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@LeaveID",LWid),
                new SqlParameter("@LeaveWord",word)
            };
            return COM.SqlHelper.ExecuteNonQuery("sp_DeleteLeaveWord", param);
        }
        public bool UpdateLeaveWord(int LWid)
        {
            //SqlParameter[] param = new SqlParameter[]
            //{
            //    new SqlParameter("@LeaveID",leaveWord.LeaveID),
            //    new SqlParameter("@userID",leaveWord.UserName),
            //    new SqlParameter("@userIp",leaveWord.UserIp),
            //    new SqlParameter("@content",leaveWord.Content),
            //    new SqlParameter("@inTime",leaveWord.Intime)
            //};
            return COM.SqlHelper.ExecuteNonQuery("sp_UpdateLeaveWord");
        }
        public DataSet SelecteLeaveWord(int LWid)
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@LWid",LWid)
            };
            return COM.SqlHelper.ExecuteQuery("sp_SelecteLeaveWord", param);
        }
        public DataSet SelectAllWord(int pageIndex, int pageSize, out int num, string returnstring)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@count",SqlDbType.Int)
            };
            parms[0].Direction = ParameterDirection.Output;
            return COM.SqlHelper.ExecuteQuery("sp_SelectAllWord",parms, pageIndex,pageSize, out num, returnstring);
        }
     
    }
}
